import re

str5 = 'one two three     four       five'
# 去除左、右1个空格
print(' '.join(str5.split()))
# 匹配任何空白字符
print(' '.join(re.split(r'\s+',str5.strip())))
# 使用1个空白字符替换多余的空白字符
print(re.sub(r'\s+', ' ', str5.strip()))

str6 = 'What time is it now?'
# print(re.search("now", str6))
post = re.search("now", str6)
# 符合上述要求的切片
print(str6[:post.start()] + str6[post.end():])
# 使用空白替换now
print(re.sub('now', '', str6))
# 使用新字符串替换now
print(str6.replace('now', ''))
